package com.example.smartcity4.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.smartcity4.R;
import com.example.smartcity4.javaBean.GsonBean;

import java.util.ArrayList;
import java.util.List;

public class MetroAdapter extends BaseAdapter {
private ArrayList<GsonBean.Data> data;

    public MetroAdapter(ArrayList<GsonBean.Data> data, Context context) {
        this.data = data;
        this.context = context;
    }

    private Context context;
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView= LayoutInflater.from(context).inflate(R.layout.metro_item,parent,false);
        TextView textView1=convertView.findViewById(R.id.metro_name);
        TextView textView2=convertView.findViewById(R.id.metro_next_name);
        TextView textView3=convertView.findViewById(R.id.metro_time);
        textView1.setText(data.get(position).lineName);
        textView2.setText("下一站"+data.get(position).nextStep.name);
        textView3.setText("到站时间"+data.get(position).reachTime+"分钟");
        return convertView;
    }
}
